﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ICalendar.CalendarProperties
{
    /// <summary>
    /// This property defines whether an event is transparent or not to busy time searches.
    /// </summary>
    /// <remarks>
    /// Time Transparency is the characteristic of an event that determines whether it appears to consume time on a calendar. Events that consume actual time for the individual or resource associated with the calendar SHOULD be recorded as OPAQUE, allowing them to be detected by free-busy time searches. Other events, which do not take up the individual's (or resource's) time SHOULD be recorded as TRANSPARENT, making them invisible to free-busy time searches.
    /// </remarks>
    /// <value>Default value is OPAQUE</value>
    [XmlRoot("transp")]
    [Serializable]
    public class Transparent : CalendarPropertyBase<bool>
    {

        public Transparent() : base(false)
         {
            
        }

        public Transparent(bool value) : base(value)
        {
            
        }
        protected override void SetValue(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                this.Value = false;
            }
            else
            {
                if (value.ToUpperInvariant() == "OPAQUE")
                    this.Value = false;
                else if (value.ToUpperInvariant() == "TRANSPARENT")
                    this.Value = true;
            }
            
        }

        protected override string GetValue()
        {
            return this.Value ? "TRANSPARENT" : "OPAQUE";
        }

        protected override void SetParametersFromXParameters(XParameterCollection xparams)
        {
            
        }

        protected override XParameterCollection GetXParametersFromParameters()
        {
            return null;
        }

        protected override string[] GetXReservedParametersNames()
        {
            return null;
        }

        public static implicit operator Transparent(bool value)
        {
            return new Transparent(value);
        }

    }
}
